'use strict';

var _regenerator = require('babel-runtime/regenerator');

var _regenerator2 = _interopRequireDefault(_regenerator);

var _asyncToGenerator2 = require('babel-runtime/helpers/asyncToGenerator');

var _asyncToGenerator3 = _interopRequireDefault(_asyncToGenerator2);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

//@charset "utf-8"
$((0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee2() {
	var clientInterface, code, market, mCode;
	return _regenerator2.default.wrap(function _callee2$(_context2) {
		while (1) {
			switch (_context2.prev = _context2.next) {
				case 0:
					_context2.prev = 0;
					clientInterface = new ComClientInterface();

					clientInterface.modifyWindowsSize('442', '416', 'Center');

					code = getUrlParam('code');
					market = getUrlParam('market');

					$('#view_stock_input').attr('data-market', market);

					if (!(code === '')) {
						_context2.next = 11;
						break;
					}

					_context2.next = 9;
					return hqQuote.request(condition.render, '17:600000', 'now', '600000');

				case 9:
					_context2.next = 16;
					break;

				case 11:
					mCode = market + ':' + code;

					$("#view_stock_input").val(code);
					//console.log($('#view_stock_input').val()+"condition.bindEvent");
					_context2.next = 15;
					return hqQuote.request(condition.render, mCode, 'now', code);

				case 15:

					condition.bindEvent();

				case 16:

					stockInput.bindEvent();
					//console.log($('#view_stock_input').val()+"stockInput.bindEvent");
					_context2.next = 22;
					break;

				case 19:
					_context2.prev = 19;
					_context2.t0 = _context2['catch'](0);

					alert(_context2.t0.message);

				case 22:

					$("#wencai").on('click', (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee() {
						var stockcode;
						return _regenerator2.default.wrap(function _callee$(_context) {
							while (1) {
								switch (_context.prev = _context.next) {
									case 0:
										stockcode = $("#view_stock_input").val().substring(0, 6);
										_context.next = 3;
										return clientInterface.openAskEarlyWebDlg("stockcode=" + stockcode);

									case 3:
									case 'end':
										return _context.stop();
								}
							}
						}, _callee, this);
					})));

				case 23:
				case 'end':
					return _context2.stop();
			}
		}
	}, _callee2, this, [[0, 19]]);
})));

//获取预警信息
//var clientInterface = new ComClientInterface();
//var subscribeDataStr = await clientInterface.getSubData();
/*	var modestr = await clientInterface.getDefaultAlertMode();
	setTimeout(function () {

		var arrmode_m = modestr.split(",");
		//alert('获取之前的'+arrmode_m);
		if(modestr != ''){
			if(arrmode_m[0] == 1){
				$("#keep_monitor").addClass("c-on");
			}else{
				$("#keep_monitor").removeClass("c-on");
			}
			if(arrmode_m[1] == 1){
				$("#show_pop").addClass("c-on");
			}else{
				$("#show_pop").removeClass("c-on");
			}
			if(arrmode_m[5] == 1){
				$("#keep_iphone").addClass("c-on");
			}else{
				$("#keep_iphone").removeClass("c-on");
			}
			if(arrmode_m[2] == 1){
				if(arrmode_m[4] == 'alert'){
					$("#soundid").find('[value="alert"]').get(0).selected = true;
				}else if(arrmode_m[4] == 'up'){
					$("#soundid").find('[value="up"]').get(0).selected = true;
				}else if(arrmode_m[4] == '清脆'){
					$("#soundid").find('[value="清脆"]').get(0).selected = true;
				}

			}else{
				$("#show_sounds").removeClass("c-on");
				$("#soundid").hide();

			}
		}*/

/*if (subscribeDataStr != '') {
			var subscribeData = eval("data="+subscribeDataStr);
       var length = subscribeData.length;
       for(var i=0; i<length; i++){
       	var stockcode = subscribeData[i]['datainfo']['stockcode'];
       	if(code == stockcode){
       		var pcid = subscribeData[i]['pcid'];
       		var mobileid = subscribeData[i]['mobileid'];
       		var platform = subscribeData[i]['platform'];
       		var appname = subscribeData[i]['appname'];
       		var templates = subscribeData[i]['datainfo']['templates'];
       		var value = subscribeData[i]['datainfo']['value'];
       		var mode = subscribeData[i]['datainfo']['mode'];
       		var arrmode = mode.split(",");
       		var stockname = subscribeData[i]['datainfo']['stockname'];
       		$("#view_stock_input").val(code+' '+stockname);
       		if(templates == 'a'){
       			$("#view_price_up_input").attr('pcid',pcid);
   				$("#view_price_up_input").val(value);
				$("#view_price_up").click();
    			$("#view_price_up").addClass("c-on");
       		}
       		if(templates == 'b'){
       			$("#view_price_down_input").attr('pcid',pcid);
       			$("#view_price_down_input").val(value);
       			$("#view_price_down").click();
       			$("#view_price_down").addClass("c-on");
       		}
	        		if(templates == 'c'){
       			$("#view_day_zhangdiefu_input").attr('pcid',pcid);
       			$("#view_day_zhangdiefu_input").val(value);
       			$("#view_day_zhangdiefu").click();
       			$("#view_day_zhangdiefu").addClass("c-on");
       		}
       		if(templates == 'd'){
       			$("#view_day_zhangdiefu_input").attr('pcidd',pcid);
       			$("#view_day_zhangdiefu_input").val(value);
       			$("#view_day_zhangdiefu").click();
       			$("#view_day_zhangdiefu").addClass("c-on");
       		}
       		if(templates == 'e'){
       			$("#view_fivemin_zhangdiefu_input").attr('pcid',pcid);
       			$("#view_fivemin_zhangdiefu_input").val(value);
       			$("#view_fivemin_zhangdiefu").click();
       			$("#view_fivemin_zhangdiefu").addClass("c-on");
       		}
       		if(templates == 'f'){
       			$("#view_fivemin_zhangdiefu_input").attr('pcidd',pcid);
       			$("#view_fivemin_zhangdiefu_input").val(value);
       			$("#view_fivemin_zhangdiefu").click();
       			$("#view_fivemin_zhangdiefu").addClass("c-on");
       		}
       		if(templates == 'g'){
       			$("#view_gonggao_input").attr('pcid',pcid);
       			$("#view_gonggao").click();
       			$("#view_gonggao").addClass("c-on");
       		}
       		if(templates == 'h'){
       			$("#view_huanshoulv_input").attr('pcid',pcid);
       			$("#view_huanshoulv_input").val(value);
       			$("#view_huanshoulv").click();
       			$("#view_huanshoulv").addClass("c-on");
       		}
       		if(templates == 'i'){
       			$("#view_one_chengjiaoliang_input").attr('pcid',pcid);
       			$("#view_one_chengjiaoliang_input").val(value);
       			$("#view_one_chengjiaoliang").click();
       			$("#view_one_chengjiaoliang").addClass("c-on");
       		}
       		if(arrmode[0] == 1){
       			$("#keep_monitor").addClass("c-on");
       		}else{
       			$("#keep_monitor").removeClass("c-on");
       		}
       		if(arrmode[1] == 1){
       			$("#show_pop").addClass("c-on");
       		}else{
       			$("#show_pop").removeClass("c-on");
       		}
       		if(arrmode[2] == 1){
       			if(arrmode[4] == 'alert'){
					$("#soundid").find('[value="alert"]').get(0).selected = true;
				}else if(arrmode[4] == 'up'){
					$("#soundid").find('[value="up"]').get(0).selected = true;
				}else if(arrmode[4] == '清脆'){
					$("#soundid").find('[value="清脆"]').get(0).selected = true;
				}
       		}else{
       			$("#show_sounds").removeClass("c-on");
       			$("#soundid").hide();
	        		}
       	}
       }
}*/
/*}, 100);*/